package com.evon.yardmanagement.transformer;

import java.util.ArrayList;
import java.util.List;

import org.dozer.DozerBeanMapper;

import com.evon.yardmanagement.model.Role;
import com.evon.yardmanagement.ui.dto.RoleDTO;

/**
 * Class responsible for converting business model into dto.
 * 
 * @author vgaurav
 * 
 */
public class RoleTransformer {
	static DozerBeanMapper mapper = new DozerBeanMapper();

	public static RoleDTO transformToDTO(Role role) {
		RoleDTO roleDTO = new RoleDTO();
		mapper.map(role, roleDTO);
		return roleDTO;
	}

	public static List<RoleDTO> transformToDTO(List<Role> roles) {
		List<RoleDTO> roleDTOList = new ArrayList<RoleDTO>();
		for (Role roleObj : roles) {
			RoleDTO roleDTO = new RoleDTO();
			mapper.map(roleObj, roleDTO);

			roleDTOList.add(roleDTO);
		}

		return roleDTOList;
	}

	public static Role transformToModel(RoleDTO roleDTO) {
		Role role = new Role();
		mapper.map(roleDTO, role);
		return role;
	}

}
